home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / kernel.h < prev    next >
C/C++ Source or Header  |  1994-04-25  |  14KB  |  392 lines

  1. /*****************************************************************************
  2.   FILE           : kernel.h
  3.   SHORTNAME      : kernel.h
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS Kernel Function Prototypes
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Niels Mache
  10.   DATE           : 20.02.90
  11.  
  12.   CHANGED BY     : Michael Vogt, Guenter Mamier
  13.   IDENTIFICATION : @(#)kernel.h    1.16 4/8/94
  14.   SCCS VERSION   : 1.16
  15.   LAST CHANGE    : 4/8/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #ifndef _KENREL_DEFINED_
  21. #define  _KENREL_DEFINED_
  22.  
  23.  
  24. /*#################################################
  25.  
  26. GROUP:  Parallel kernel functions
  27.  
  28. #################################################*/
  29.  
  30. #ifdef  MASPAR_KERNEL
  31. /*  Connects and Disconnects the MasPar.
  32.     The mode switches are:  MASPAR_CONNECT and MASPAR_DISCONNECT. */
  33. extern krui_err  kr_initMasPar( int  mode );
  34.  
  35. /* Returns the Status of the MasPar or an error code.*/
  36. extern krui_err  kr_getMasParStatus( void );
  37. #endif
  38.  
  39. /*  Validate a network modifying operation according to
  40.     the kernel mode. */
  41. extern krui_err  kr_validateOperation( void );
  42.  
  43. /*  Sets the topologic type of the current network.
  44.     Returns an error if the topologic type of the current network  
  45.     doesn't fit to this type.
  46.     Topologic types are:
  47.       - NET_TYPE_GENERAL
  48.         general purpose network type with no limitations
  49.       - NET_TYPE_FF1
  50.         feedforward network with fully connected units in
  51.         neighbour layers */
  52. extern krui_err  kr_setSpecialNetworkType( int  net_type );
  53.  
  54. /*  Returns the special topologic type of the current network, if set. */
  55. extern int  kr_getSpecialNetworkType( void );
  56.  
  57. /*  Creates a user defined unit. */
  58. extern int  kr_createUnit(char *unit_name, char *out_func_name, 
  59.               char *act_func_name, FlintTypeParam i_act, 
  60.               FlintTypeParam  bias );
  61.  
  62. /*  Deletes all input links at current unit/site. */
  63. extern krui_err  kr_deleteAllLinks( int  mode );
  64.  
  65.  
  66. /*  Deletes the current link.
  67.     NOTE: To delete a link between the current unit/site and the source unit
  68.       <source_unit_no>, call krui_isConnected( source_unit_no ) and
  69.       krui_deleteLink(). */
  70. extern krui_err  kr_deleteLink( void );
  71.  
  72.  
  73. /*  Creates a link between source unit and the current unit/site.
  74.     Returns an error code:
  75.      - if memory allocation fails
  76.      - if source unit doesn't exist or
  77.      - if there exists already a connection between current unit/site and
  78.        the source unit
  79.     0 otherwise.
  80.     kr_createLink DO NOT set the current link.
  81.  
  82. NOTE: If you want to create a link and its unknown if there exists already a
  83.       connection between the two units, use krui_createLink and test the return
  84.       code, instead of the sequence kr_isConnected and kr_createLink. */
  85. extern krui_err  kr_createLink( int  source_unit_no, FlintTypeParam  weight );
  86.  
  87.  
  88. /*  Sets the link weight of the current link*/
  89. extern void  kr_setLinkWeight( FlintTypeParam    weight );
  90.  
  91.  
  92. /*  Returns the link weight of the current link.*/
  93. extern FlintType  kr_getLinkWeight( void );
  94.  
  95.  
  96. /*  True if there exists a connection between source unit <source_unit_no>
  97.     and the current unit/site, otherwise false.
  98.     NOTE: If there exists a connection between the two units, the current 
  99.       link is set to the link between the two units.*/
  100. extern bool  kr_isConnected( int  source_unit_no, FlintType   *weight );
  101.  
  102.  
  103. /*  True if there exists a connection between source unit <source_unit_no>
  104.     and target unit <target_unit_no>, otherwise false. If there exist a
  105.     connection between these units, kr_areConnected returns the connection
  106.     strength also.
  107.     Returns FALSE if unit doesn't exist.
  108.     IMPORTANT: If there exist a connection, the current unit and site will be
  109.        set to the target unit/site.
  110.     NOTE: This function is slow (Units are backward chained only).*/
  111. extern bool  kr_areConnected( int  source_unit_no, int  target_unit_no,
  112.                  FlintType   *weight );
  113.  
  114. /*  Returns the no. of first or next succecessor unit of the given unit and 
  115.     the connection strenght. Sets the current unit/site.*/
  116. extern int  kr_getSuccessorUnit(int mode, int source_unit_no, 
  117.                 FlintType  *weigth );
  118.  
  119.  
  120. /*  initialize the first/next site or the named site at the current unit
  121.     for access */
  122. extern int  kr_setSite( int  mode, char  *site_name );
  123.  
  124. /*  initializes the given unit for access*/
  125. extern krui_err  kr_setCurrUnit( int  unit_no );
  126.  
  127. /*  returns the number of the first/next/current unit of the unit array*/
  128. extern int  kr_getUnit( int  mode );
  129.  
  130. /*  Returns the no. of first, next or current predecessor unit of the
  131.     current unit/site and the connection weight.*/
  132. extern int  kr_getPredecessorUnit( int  mode, FlintType  *weight );
  133.  
  134.  
  135. /*  Remove unit and all links from network.*/
  136. extern krui_err  kr_removeUnit( struct Unit  *unit_ptr );
  137.  
  138. /*  Returns the value of the specified unit component.*/
  139. extern FlintType   kr_getUnitValues( int  unit_no, int  component_selector );
  140.  
  141. /*  Sets the value of the specified unit component.*/
  142. extern krui_err  kr_setUnitValues( int  unit_no, int  component_selector,
  143.                   FlintTypeParam  value );
  144.  
  145. /*  Sets all unit components of the specified unit.*/
  146. extern krui_err  kr_setAllUnitValues( int unit_no, FlintTypeParam out, 
  147.                      FlintTypeParam act, FlintTypeParam i_act, 
  148.                      FlintTypeParam bias );
  149.  
  150. /*  delete all inputs at the given unit*/
  151. extern void kr_deleteAllInputs( struct Unit  *unit_ptr );
  152.  
  153. /*  Deletes all output links at <source_unit>
  154.     NOTE: This function is slow.*/
  155. extern void kr_deleteAllOutputLinks( struct Unit  *source_unit_ptr );
  156.  
  157. /*  search for a site at a unit */
  158. extern struct Site *kr_searchUnitSite( struct Unit  *unit_ptr, 
  159.                       struct SiteTable  *stbl_ptr );
  160.  
  161. /*  search for a site at a unit and returns also the predecessor site ptr */
  162. extern void kr_searchUnitSiteWithPred( struct Unit  *unit_ptr, 
  163.                       struct SiteTable  *stbl_ptr,
  164.                       struct Site  * *Rsite_ptr, 
  165.                       struct Site  * *Rsite_pred_ptr );
  166.  
  167. /*  searches for a site in the network */
  168. extern int kr_searchNetSite( struct SiteTable  *stbl_ptr );
  169.  
  170. /*  Creates a new site with default initialisation*/
  171. extern struct Site *kr_createDefaultSite( void );
  172.  
  173. /*  returns the pointer to the given unit, returns NULL if unit doesn't exist*/
  174. extern struct Unit *kr_getUnitPtr( int  unit_no );
  175.  
  176. /*  Searches for a unit with the given symbol pointer.
  177.     Returns the first unit no. if a unit with the given name was found,
  178.     0 otherwise. */
  179. extern int kr_unitNameSearch( int  min_unit_no, char  *unit_symbol_ptr );
  180.  
  181. /*  Creates a unit with default values.*/
  182. extern int  kr_makeDefaultUnit( void );
  183.  
  184.  
  185. /*  Copy a given unit, according to the copy mode
  186.         1. copy unit (with it sites, if available) and input/output links
  187.         2. copy unit (with it sites, if available) and input links
  188.         3. copy unit (with it sites, if available) and output links
  189.         4. copy unit (with it sites, if available) but no input/output links
  190.  
  191.     Returns the unit number of the new unit or error message < 0 , if errors 
  192.     occured. Function has no effect on the current unit.
  193.  
  194.     NOTE: Copying of output links is slow.
  195.       If return code < 0, an error occured.*/
  196. extern krui_err  kr_copyUnit( int  copy_mode, int  source_unit );
  197.  
  198. /*  Sets the topologic type of the unit.*/
  199. extern krui_err  kr_unitSetTType( int  unit_no, int  UnitTType );
  200.  
  201.  
  202. /*  changes all units in the network with the given functionality type
  203.     to the new functions of the (new) functionality type */
  204. extern void kr_changeFtypeUnits( struct  FtypeUnitStruct  *Ftype_entry );
  205.  
  206. /*   delete the functionality type of the units with the given type*/
  207. extern void kr_deleteUnitsFtype( struct  FtypeUnitStruct  *ftype_ptr );
  208.  
  209. /*  create a new unit with the given functionality type*/
  210. extern int  kr_makeFtypeUnit( char  *Ftype_symbol );
  211.  
  212. /*  returns TRUE, if there exists the given site at the given ftype entry*/
  213. extern bool kr_FtypeSiteSearch( struct  Site  *ftype_first_site, struct  SiteTable  *site_table_ptr );
  214.  
  215. /*  change the properties of the given unit to the properties of the
  216.     given F-Type */
  217. extern void kr_changeFtypeUnit( struct  Unit  *unit_ptr, struct  FtypeUnitStruct  *ftype_ptr );
  218.  
  219. /*  change a site at the F-Type*/
  220. extern void kr_changeFtypeSites( struct  FtypeUnitStruct  *Ftype_entry, 
  221.                           struct  SiteTable  *old_site_table,
  222.                           struct  SiteTable  *new_site_table );
  223.  
  224. /*  spell checker  (check identifiers for matching [A-Za-z]^[|, ]*)*/
  225. extern bool kr_symbolCheck( char    *symbol );
  226.  
  227. /*  translate unit flags to the topological type of the unit*/
  228. extern int kr_flags2TType( int  flags );
  229.  
  230. /*  translate the topological type to unit flags*/
  231. extern int kr_TType2Flags( int  ttype );
  232.  
  233. /*  update the outputs of all units in the network*/
  234. extern void kr_updateUnitOutputs( void );
  235.  
  236. /*  returns the no. of units of the specified topologic type
  237.     (i.e. Input, Hidden, Output or Special units)*/
  238. extern int kr_getNoOfUnits( int  UnitTType );
  239.  
  240. /*  force unit array garbage collection*/
  241. extern void  kr_forceUnitGC( void );
  242.  
  243.  
  244. /*#################################################
  245.  
  246. GROUP: Topological Sorting Functions
  247.  
  248. #################################################*/
  249.  
  250.  
  251. /*  Sort units according to the given mode:
  252.     TOPOLOGICAL:
  253.       Sort units topological (general version) and stores the
  254.       pointers to this units in the topologic array.
  255.       NOTE: Units are not sorted by their topologic type (that's not
  256.         possible in general case).
  257.  
  258.     TOPOLOGICAL_FF:
  259.       Sorts unit topological in feed-forward networks and stores the
  260.       pointers to this units in the topologic array in the following order:
  261.        - input,
  262.        - hidden and
  263.        - output units
  264.  
  265.       This function make following assumtions (like all learning functions for
  266.       feed-forward networks):
  267.        a) input units doesn't have input connections to other units and
  268.        b) output units doesn't have outputs connections to other units.
  269.  
  270.     TOPOLOGIC_TYPE:
  271.       Sort units by their topologic type, i.e. Input, Hidden, Output units and
  272.       stores the pointers to this units in the topologic array. */
  273. extern krui_err kr_topoSort( int sort_mode );
  274.  
  275.  
  276. /*  Checks the topology of the network:
  277.      a) counts the number of layers of the network and
  278.      b) determines if the network has cycles.
  279.  
  280.     Returns the no. of layers of the network.*/
  281. extern int kr_topoCheck( void );
  282.  
  283. /*  Count the no. of input and output units and return an error code
  284.     if the no. do not fit to the loaded patterns.*/
  285. extern krui_err  kr_IOCheck( void );
  286.  
  287. extern krui_err  kr_makeUnitPermutation( void );
  288.  
  289. /*#################################################
  290.  
  291. GROUP: Other functions
  292.  
  293. #################################################*/
  294.  
  295. /*  Add random uniform distributed values to connection weights.
  296.     <minus> must be less then <plus>.*/
  297. extern void kr_jogWeights( FlintTypeParam  minus, FlintTypeParam  plus );
  298.  
  299. /*  calls a network function */
  300. extern krui_err  kr_callNetworkFunction(int type, float *parameterInArray, 
  301.                     int  NoOfInParams,
  302.                     float  * *parameterOutArray, 
  303.                     int  *NoOfOutParams, int start_pattern,
  304.                     int  end_pattern );
  305.  
  306. /*  Returns information about the unit default settings. */
  307. extern void kr_getUnitDefaults( FlintType *act, FlintType *bias, int *ttflags,
  308.                    int  *subnet_no, int  *layer_no, 
  309.                    char * *act_func, char * *out_func );
  310.  
  311. /*  Changes the unit default settings. */
  312. extern krui_err kr_setUnitDefaults( FlintTypeParam  act, FlintTypeParam  bias,
  313.                    int  ttflags, int subnet_no, int  layer_no, 
  314.                    char  *act_func_ptr, char  *out_func_ptr );
  315.  
  316.  
  317.  
  318. /*#################################################
  319.  
  320. GROUP: Global Var's
  321.  
  322. #################################################*/
  323.  
  324. extern bool  NetModified,    /*  TRUE, if the network topology was modified  */
  325.              NetInitialize,  /*  TRUE, if the network has been initialized   */
  326.         LearnFuncHasChanged ;/*  TRUE, if the learning function has changed  */
  327.  
  328. extern FlagWord  DefaultSType;  /*  default topological type    */
  329.  
  330. extern int  NoOfUnits,    /*  no. of units in the network  */
  331.             MinUnitNo,    /*  the first (lowest) used unit no. in the network */
  332.             MaxUnitNo,    /*  the last (highest) used unit no. in the network */
  333.             NoOfInputUnits,    /*  no. of input units    */
  334.             NoOfOutputUnits,    /*  no. of output units  */
  335.             NoOfHiddenUnits,    /*  no. of hidden units  */
  336.             TopoSortID;         /*  topologic mode identifier  */
  337.  
  338. extern UnitArray   unit_array;  /*  the unit array  */
  339.  
  340. extern TopoPtrArray topo_ptr_array;  /* pointers to topological sorted units
  341.                     used by kr_topoSort()  */
  342.  
  343. extern int  no_of_topo_units;  /*  no. of unit pointers in topo_ptr_array  */
  344.  
  345.  
  346. /*  Kernel Interface Error Code */
  347. extern krui_err  KernelErrorCode;
  348.  
  349. /*  File I/O: Line number of the network file. */
  350. extern int  lineno;
  351.  
  352. /*  Stores the error codes and messages of the topologic sorting and network 
  353.     checking functions. */
  354. extern struct TopologicMessages  topo_msg;
  355.  
  356.  
  357. /*  Pointers and numbers for storing the current unit, site or link.
  358.     Used by unit/site/link searching routines. */
  359. extern struct Unit  *unitPtr;
  360. extern struct Site  *sitePtr,
  361.                 *prevSitePtr;
  362. extern struct Link  *linkPtr,
  363.                 *prevLinkPtr;
  364. extern int  unitNo;
  365.  
  366.  
  367. extern int   specialNetworkType;   /* stores the topologic type of a network */
  368.  
  369. #ifdef MASPAR_KERNEL
  370.  
  371. /*#################################################
  372.  
  373. GROUP:  Global var's of the parallel MasPar kernel
  374.  
  375. #################################################*/
  376.  
  377. extern int   masParStatus;        /*  holds the status of the MasPar */
  378.  
  379. /*  stores the topologic description of a feedforward network */
  380. extern struct FFnetDescriptor  descrFFnet,
  381.                                descrFFnetIO;
  382.  
  383. #endif
  384.  
  385.  
  386.  
  387.  
  388.  
  389. #endif  /* _KERNEL_DEFINED_ */
  390.  
  391. /* 411 lines generated by deleteprivatedefinitions.awk */
  392.